<template>
  <view class="service-center-page">
    <!-- 顶部导航栏 -->
    <view class="page-header">
      <view class="header-inner">
        <view class="back-btn" @click="handleBack">
          <u-icon name="arrow-left" color="#1f2937" size="18"></u-icon>
        </view>
        <text class="header-title">服务中心</text>
        <view class="home-btn" @click="handleHome">
          <u-icon name="home" color="#1f2937" size="18"></u-icon>
        </view>
      </view>
    </view>

    <scroll-view scroll-y class="content-scroll">
      <!-- 服务中心介绍 Banner -->
      <view class="banner-section">
        <image src="/static/images/banner/banner02.jpg" mode="aspectFill" class="banner-bg"></image>
        <view class="banner-mask"></view>
        <view class="banner-content">
          <view class="banner-icon">
            <u-icon name="grid" color="#ffffff" size="24"></u-icon>
          </view>
          <text class="banner-title">全方位农业服务</text>
          <text class="banner-desc">一站式解决农业生产经营需求</text>
        </view>
      </view>

      <!-- 服务统计 -->
      <view class="stats-section">
        <view class="stats-card">
          <view class="stats-grid">
            <view class="stat-item">
              <text class="stat-value color-primary">6+</text>
              <text class="stat-label">服务类别</text>
            </view>
            <view class="stat-divider"></view>
            <view class="stat-item">
              <text class="stat-value color-secondary">200+</text>
              <text class="stat-label">服务商家</text>
            </view>
            <view class="stat-divider"></view>
            <view class="stat-item">
              <text class="stat-value color-accent">1000+</text>
              <text class="stat-label">服务订单</text>
            </view>
            <view class="stat-divider"></view>
            <view class="stat-item">
              <text class="stat-value color-primary">99%</text>
              <text class="stat-label">好评率</text>
            </view>
          </view>
        </view>
      </view>

      <!-- 服务类别列表 -->
      <view class="services-list">
        <view 
          v-for="(service, index) in services" 
          :key="index"
          class="service-card"
          @click="handleServiceClick(service)"
        >
          <view class="card-image-wrap">
            <image :src="service.image" mode="aspectFill" class="card-image"></image>
            <view class="card-mask"></view>
            <view class="card-content">
              <view class="content-header">
                <view class="icon-wrap">
                  <u-icon :name="service.icon" color="#ffffff" size="20"></u-icon>
                </view>
                <view class="header-info">
                  <text class="service-title">{{ service.title }}</text>
                  <text class="service-desc">{{ service.desc }}</text>
                </view>
              </view>
              <view class="content-footer">
                <view class="stats-info">
                  <view class="info-item">
                    <u-icon name="bag" size="10" color="#ffffff"></u-icon>
                    <text class="info-text">{{ service.merchants }} 服务商</text>
                  </view>
                  <view class="info-item">
                    <u-icon name="checkbox-mark" size="10" color="#ffffff"></u-icon>
                    <text class="info-text">已完成 {{ service.orders }} 单</text>
                  </view>
                </view>
                <view class="view-btn">
                  <text class="btn-text">查看详情</text>
                  <u-icon name="arrow-right" size="10" color="#ffffff"></u-icon>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>

      <!-- 底部安全区 -->
      <view class="safe-bottom"></view>
    </scroll-view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

// 服务类别数据
const services = ref([
  {
    title: '农机服务',
    desc: '耕地、播种、收割全流程',
    icon: 'setting',
    image: 'https://images.unsplash.com/photo-1625246333195-78d9c38ad449?w=600&h=400&fit=crop&q=90',
    merchants: '50+',
    orders: '320'
  },
  {
    title: '金融贷款',
    desc: '低息贷款，快速审批',
    icon: 'rmb-circle',
    image: 'https://images.unsplash.com/photo-1579621970563-ebec7560ff3e?w=600&h=400&fit=crop&q=90',
    merchants: '15+',
    orders: '180'
  },
  {
    title: '劳务派遣',
    desc: '专业农业劳务人员',
    icon: 'account',
    image: 'https://images.unsplash.com/photo-1464226184884-fa280b87c399?w=600&h=400&fit=crop&q=90',
    merchants: '30+',
    orders: '250'
  },
  {
    title: '物流代办',
    desc: '农产品物流配送',
    icon: 'car',
    image: 'https://images.unsplash.com/photo-1586528116311-ad8dd3c8310d?w=600&h=400&fit=crop&q=90',
    merchants: '40+',
    orders: '300'
  },
  {
    title: '集采代购',
    desc: '农资集采，价格优惠',
    icon: 'bag',
    image: 'https://images.unsplash.com/photo-1574943320219-553eb213f72d?w=600&h=400&fit=crop&q=90',
    merchants: '25+',
    orders: '150'
  },
  {
    title: '办公场地',
    desc: '现代化办公场地出租',
    icon: 'home',
    image: 'https://images.unsplash.com/photo-1497366216548-37526070297c?w=600&h=400&fit=crop&q=90',
    merchants: '12+',
    orders: '80'
  }
])

// 事件处理
const handleBack = () => {
  uni.navigateBack()
}

const handleHome = () => {
  uni.reLaunch({ url: '/pages/yjyny/home/index' })
}

const handleServiceClick = (service) => {
  uni.navigateTo({ url: `/pages/yjyny/service/center/detail?title=${service.title}` })
}
</script>

<style lang="scss" scoped>
.service-center-page {
  min-height: 100vh;
  background-color: #f9fafb;
}

// 顶部导航栏
.page-header {
  background-color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2rpx solid #f3f4f6;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}

.header-inner {
  display: flex;
  align-items: center;
  padding: 24rpx 32rpx;
  gap: 24rpx;
}

.back-btn,
.home-btn {
  width: 64rpx;
  height: 64rpx;
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
}

.back-btn:active,
.home-btn:active {
  background-color: #f3f4f6;
}

.header-title {
  flex: 1;
  font-size: 32rpx;
  font-weight: bold;
  color: #1f2937;
  text-align: center;
}

// 内容滚动区
.content-scroll {
  height: calc(100vh - 120rpx);
}

// Banner区域
.banner-section {
  position: relative;
  height: 384rpx;
  overflow: hidden;
}

.banner-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.1;
}

.banner-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom right, #06b6d4, #10b981, #059669);
}

.banner-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48rpx;
}

.banner-icon {
  width: 128rpx;
  height: 128rpx;
  border-radius: 32rpx;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12rpx);
  border: 4rpx solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24rpx;
}

.banner-title {
  font-size: 40rpx;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 16rpx;
}

.banner-desc {
  font-size: 28rpx;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
}

// 服务统计
.stats-section {
  padding: 48rpx 32rpx 32rpx;
}

.stats-card {
  background-color: #ffffff;
  border-radius: 32rpx;
  padding: 32rpx;
  box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
  border: 2rpx solid #f3f4f6;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 2rpx 1fr 2rpx 1fr 2rpx 1fr;
  align-items: center;
  gap: 8rpx;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16rpx 0;
}

.stat-value {
  font-size: 40rpx;
  font-weight: bold;
  margin-bottom: 8rpx;
  
  &.color-primary {
    color: #10b981;
  }
  
  &.color-secondary {
    color: #3b82f6;
  }
  
  &.color-accent {
    color: #f59e0b;
  }
}

.stat-label {
  font-size: 22rpx;
  color: #6b7280;
}

.stat-divider {
  width: 2rpx;
  height: 64rpx;
  background-color: #f3f4f6;
}

// 服务列表
.services-list {
  padding: 0 32rpx 32rpx;
  display: flex;
  flex-direction: column;
  gap: 24rpx;
}

.service-card {
  background-color: #ffffff;
  border-radius: 32rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  border: 2rpx solid #f3f4f6;
  overflow: hidden;
  transition: all 0.3s;
}

.service-card:active {
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
}

.card-image-wrap {
  position: relative;
  height: 320rpx;
}

.card-image {
  width: 100%;
  height: 100%;
}

.card-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.2), transparent);
}

.card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32rpx;
  color: #ffffff;
}

.content-header {
  display: flex;
  align-items: center;
  gap: 16rpx;
  margin-bottom: 16rpx;
}

.icon-wrap {
  width: 80rpx;
  height: 80rpx;
  border-radius: 24rpx;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12rpx);
  border: 2rpx solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.service-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 4rpx;
}

.service-desc {
  font-size: 24rpx;
  color: rgba(255, 255, 255, 0.9);
}

.content-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats-info {
  display: flex;
  align-items: center;
  gap: 24rpx;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 8rpx;
}

.info-text {
  font-size: 22rpx;
  color: #ffffff;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 8rpx;
  padding: 12rpx 24rpx;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12rpx);
  border-radius: 24rpx;
  border: 2rpx solid rgba(255, 255, 255, 0.3);
}

.btn-text {
  font-size: 22rpx;
  color: #ffffff;
}

// 底部安全区
.safe-bottom {
  height: 160rpx;
}
</style>
